package servlet;

import hadoop.HadoopUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author cheng
 * @date 2021-11-26 12:31
 */
@WebServlet("/demo2")
public class ServletDemo2 extends HttpServlet {


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // hdfs 文件读取
         String srcPath =  req.getParameter("srcPath");

        HadoopUtil hadoopUtil = new HadoopUtil();
        String  result  =  hadoopUtil.hadoopRead(srcPath);

        resp.setContentType("text/html;charset=utf-8");
        PrintWriter pw =  resp.getWriter();
        pw.write(result);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }


}
